pp108 : Defining Rule Behavior

Defining Rule Behavior

This topic describes the procedure to define rule behavior while creating a new rule.

A rule definition consists of an If ( that is, condition) part , and a Then (that is, the action) part. Rules follow a simple if-then structure. This topic covers the procedure to define these components while creating a rule.
Note:
While defining the condition, drag the required <object template> or <schema fragment> from the Workspace Documents explorer to the Input Schema in the Business Object section. Alternatively, click (Quick Access Menu) on the rule editor tool bar, click (Insert) on the Quick Access Menu sidebar, and drag the required <object template> or <schema fragment> to the Input Schema pane in the editor.

  1. Click to define a condition for the rule in the Set Condition pane
    a. Do any or a combination of the following:
    • To build the condition expression using:
      • Business Objects - Drag the required attribute from the Input Schema to the Set Condition pane.
      • Function Library - Select the required operator or function from the displayed Functions, and drag it to the Set Condition pane.
    • Type the condition in the Set Condition pane.
      Note: The expression should be a valid XPath expression. For more information on XPath, refer to the XPath link in the related topics section.
      b. Click Add in the Set Condition pane. The defined condition is displayed next to in the Rule Definition pane.
  2. Define the action the rule must perform.
    a. Do any or a combination of the following:
    • Right-click then in the Rule Definition pane, and select Actions <action>. For more information, refer to Rule Actions.
    • Right-click else in the Rule Definition pane, and select Actions <action>. For more information, refer to Rule Actions.
      b. Based on the action you select, specify the necessary information in the Action pane, and click Add. The type of action along with the name is attached to then in the Rule Definition pane. To add more actions, repeat the step.
      The rule behavior is defined.

      Attention

      • You can use object metadata while defining the rule condition or action. While typing the rule condition or rule action, use the following syntax to access the object's metadata.
        <object>/metadata/<element of the object's metadata>
      • You can compare the old and the new states of an object when it is being updated. The old values of the object can be accessed in a rule by prefixing old to the object property.For example: A business policy that states that an order cannot be modified if the ordered quantity is being reduced. The same can be translated into a constraint rule as follows:
        IF 
        ord:Order/ord:Quantity < old/ord:Order/ord:Quantity
        THEN
        Abort ('Not allowed to decrease the order quantity')
        
        The following guidelines must be followed while comparing object states:
      1. The feature of comparing the old and new states of an object applies to constraint rules when updating an object in the CoBOC.
      2. The old values of the object are read-only, and cannot be modified through rule assignment operations.

Related information

http://www.w3.org/TR/xpath